﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UCore;

namespace Twin {
    public class Const {


        public void initFromIni() {
            ReadAreas(Ini.path_Areas_ini);

            string path = Ini.dir_io_file + "\\jsonROOT.txt";
            string jsonRoot;
            try {
                jsonRoot = File.ReadAllText(path);
            } catch (Exception ex) {
                Console.WriteLine("读取文件时出错：" + ex.Message);
                return;
            }
            area_size = initLstArea(jsonRoot);        //area_name ready !


            string sAbs;
            for (int i = 0; i < area_size; i++) {
                path = Ini.dir_io_file + "\\abs" + area_name[i].ToUpper() + ".txt";     //"\\absROOT.txt";
                try {
                    sAbs = File.ReadAllText(path);
                    map_abs.Add("abs" + area_name[i].ToUpper(), sAbs);
                } catch (Exception ex) {
                    Console.WriteLine("读取文件时出错：" + ex.Message);
                    return;
                }
            }


            //ROOT
            //path = Ini.dir_io_file + "\\absROOT.txt";
            //try {
            //    sAbs = File.ReadAllText(path);
            //    map_abs.Add("absROOT", sAbs);
            //} catch (Exception ex) {
            //    Console.WriteLine("读取文件时出错：" + ex.Message);
            //    return;
            //}
            fmt_size = init_size("root.Bcfg.SizeBelt_", map_abs["absROOT"]); // sAbs);
            elem_size = init_size("root.Els.SizeElem_", map_abs["absROOT"]);


            //ACT
            //path = Ini.dir_io_file + "\\absACT.txt";
            //try {
            //    sAbs = File.ReadAllText(path);
            //    map_abs.Add("absACT", sAbs);
            //} catch (Exception ex) {
            //    Console.WriteLine("读取文件时出错：" + ex.Message);
            //    return;
            //}
            cmfg_size = init_size("act.LCmfg.SizeCmfg_", map_abs["absACT"]);


            //DEV

            //临时
            port_size = 5;

            //path = Ini.dir_io_file + "\\absDEV.txt";
            //try {
            //    sAbs = File.ReadAllText(path);
            //    map_abs.Add("absDEV", sAbs);
            //} catch (Exception ex) {
            //    Console.WriteLine("读取文件时出错：" + ex.Message);
            //    return;
            //}
            port_size = init_size("dev.LPort.SizePort_", map_abs["absDEV"]);
        }




    }
}
